<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<%@include file="/views/common/include/taglib.jsp"%>
<%@include file="/views/common/include/head.jsp"%>
<link rel="stylesheet" href="${ctx}/css/page/person.css" type="text/css">
<link rel="stylesheet" href="${ctx}/css/page/header2.css" type="text/css">
<link rel="stylesheet" href="${ctx}/css/page/reset.css" type="text/css">
<link rel="stylesheet" href="${ctx}/css/page/person-left.css" type="text/css">
<link rel="stylesheet" href="${ctx}/css/page/footer.css" type="text/css">
<style type="text/css">
    .changePw{border-radius:5px;}
    .changePw .layui-layer-title{height:50px;background:#7ECFE0;line-height:50px;color:#fff;font-size:20px;text-align:center;border-radius:5px 5px 0 0;}
    .changePw .layui-layer-setwin .layui-layer-close1{width:25px;height:25px;}.changePw .layui-layer-setwin{top:14px;}
</style>

<script src="${ctx}/js/controllers/mall/order/orderListController.js" type="text/javascript"></script>
</head>
<body>
	<jsp:include page="/views/common/head_main.jsp" />
    <div class="bg">
        <div class="contentbox1 contentbox">
	        <div class="leftlist">
		        <div class="myorder left">
					<ul>
						<li><a class="order" href="${ctx}/orderInfo/orderInfoListByState" >我的订单</a></li>
						<li><a href="${ctx}/orderInfo/orderInfoListByState?states=0">待付款</a></li>
						<li><a href="${ctx}/orderInfo/orderInfoListByState?states=1">待商家确认</a></li>
						<li><a href="${ctx}/orderInfo/orderInfoListByState?states=2">待发货</a></li>
						<li><a href="${ctx}/orderInfo/orderInfoListByState?states=3,14">待收货</a></li>
						<li><a href="${ctx}/orderInfo/orderInfoListByState?states=6,7,8,10,11,12,13">退款售后</a></li>
					</ul>
				</div>
				<div class="myproperty left">
					<ul>
						<li class="order">我的物业</li>
						<c:if test="${displayFeeBill == 1}">
						<li><a href="${ctx}/propertyBill/getMyBill">我的物业费</a></li>
						</c:if>
						<c:if test="${displayCar == 1}">
						<li><a href="${ctx}/carBill/getCarManage">我的停车费</a></li>
						</c:if>
						<li><a href="${ctx}/propertyRepair/infoList">我的物业报修</a></li>
						<li><a href="${ctx}/propertySuggestion/infoList">我的物业投诉</a></li>
					</ul>
				</div>
				<div class="myassets left">
					<ul>
						<li class="order" >我的资产</li>
					    <li><a href="${ctx}/ownerTreasure/ownerIntegralChangeList?state=0&pNo=1">我的积分</a></li>
						<li><a href="${ctx}/ownerTreasure/getCouponList?pNo=1">优惠券</a></li>
					</ul>
				</div>
				<div class="otherlist left">
					<ul class="others">
						<li class="order">其他</li>
						<li><a href="${ctx}/ownerOther/getMyCollection">我的收藏</a></li>
						<li><a href="${ctx}/ownerAddress/ownerAddressList">我的收货地址</a></li>
						<li><a href="${ctx}/complaintsInfo/infoList">我的投诉建议</a></li>
						<li><a href="${ctx}/ownerHouse/ownerHouseList">我的小区</a></li>
						<!-- position需要跳转到特定位置 -->
						<li><a href="${ctx}/main?item=1#openShop">我要开店</a></li>
						<li><a href="${ctx}/usualQuestions/infoList">常见问题</a></li>
					</ul>
				</div>
			</div>
            <div class="rightlist" style="background: #D6EAF1;">
                <div class="userbox">
                    <div class="user userlist">
                        <div class="padd1">
                        	<div class="wrap-box">
	                            <div class="photo">
 		                            <c:if test="${ not empty userInfo.logo}"> 
 	                                      <img width="96px" height="96px" src="${sessionScope.image_logo}${userInfo.logo}" /> 
	                                </c:if> 
	                                <c:if test="${ empty userInfo.logo}"> 
	                                       <img src="${ctx}/images/page/pe1.png">
	                                </c:if> 
	                               
	                            </div>
	                            <div class="nameandphone">
	                            <input type="hidden" id="currentUserId" value="${userInfo.id}"/>
	                               <p>${userInfo.nickname}</p>
	                               <p> ${userInfo.phone}<a href="${ctx}/user/userCheck"><img src="${ctx}/images/grzx/gr4.png" class="phone-pic"></a></p>
	                            </div>
	                           
                            </div>
                             <div class="xinxi">
	                                <span class="jiange"><a href="${ctx}/user/changePersonInfo?id=${userInfo.id}"><img src="${ctx}/images/grzx/gr1.png" />个人信息</a></span>
	                                <span class="jiange middle-space"><a onclick="changePassword(${userInfo.id})"><img src="${ctx}/images/grzx/gr2.png" />修改密码 </a></span>
	                                <span class="jiange"><a onclick="SignIn()"><img src="${ctx}/images/grzx/gr3.png" />签到</a></span>
                            </div>
                            
                        </div>
                    </div>
                    <div class="payment userlist">
                        <div class="padd">
                            <ul>
                                <li><a href="${ctx}/orderInfo/orderInfoListByState?states=0"><img src="${ctx}/images/page/pe2.png" /><br/>
	                                <c:if test="${fn:length(waitPayMoneyOrderList) >= 99}"> 
	                                	<span>待付款<span class="num"> ${fn:length(waitPayMoneyOrderList)}<sup>+</sup></span></span>
 	                                </c:if> 
	                                <c:if test="${fn:length(waitPayMoneyOrderList) < 99}"> 
	                                	<span>待付款<span class="num"> ${fn:length(waitPayMoneyOrderList)}</span></span>
	                                </c:if>
	                                </a></li>
                                <li><a href="${ctx}/orderInfo/orderInfoListByState?states=2"><img src="${ctx}/images/page/pe3.png" /><br/>
	                                <c:if test="${fn:length(waitSendGoodsOrderList) >= 99}">
	                                	<span>待发货<span class="num"> ${fn:length(waitSendGoodsOrderList)}<sup>+</sup></span></span>
	                                </c:if>
	                                <c:if test="${fn:length(waitSendGoodsOrderList) < 99}">
	                                	<span>待发货<span class="num"> ${fn:length(waitSendGoodsOrderList)}</span></span>
	                                </c:if>
	                                </a></li>
                                <li><a href="${ctx}/orderInfo/orderInfoListByState?states=3,14"><img src="${ctx}/images/page/pe4.png" /><br/>
	                                <c:if test="${fn:length(waitReceiveGoodsOrderList) >= 99}">
	                                	<span>待收货<span class="num"> ${fn:length(waitReceiveGoodsOrderList)}<sup>+</sup></span></span>
	                                </c:if>
	                                <c:if test="${fn:length(waitReceiveGoodsOrderList) < 99}">
	                                	<span>待收货<span class="num"> ${fn:length(waitReceiveGoodsOrderList)}</span></span>
	                                </c:if>
	                                </a></li>
                                <li><a href="${ctx}/orderInfo/orderInfoListByState?states=4,6,7,8,10,11,12,13"><img src="${ctx}/images/page/pe5.png" /><br/>
	                                <c:if test="${fn:length(waitCommentOrderList) >= 99}">
	                                	<span>待评论<span class="num"> ${fn:length(waitCommentOrderList)}<sup>+</sup></span></span>
	                                </c:if>
	                                <c:if test="${fn:length(waitCommentOrderList) < 99}">
	                                	<span>待评论<span class="num"> ${fn:length(waitCommentOrderList)}</span></span>
	                                </c:if>
	                                </a></li>
                            </ul>
                        </div>
                        
                    </div>
                    <div class="jifen userlist">
                        <div class="padd">
                            <p>我的积分：<span class="num">${userInfo.integral}</span> <span><a href="${ctx}/mallIntegral">【兑换】</a></span></p>
                            <div class="imgbox"><a href="${ctx}/ownerTreasure/ownerIntegralChangeList?state=0&pNo=1"><img src="${ctx}/images/page/pe6.png"/></a></div>
                            <p>我的优惠券<span class="num"> ${fn:length(couponInfoList)} </span>张</p>
                            <p class="exp"><img src="${ctx}/images/grzx/gr5.png"><a href="" style="text-decoration:underline">积分说明</a></p>
                        </div>
                    </div>
                </div>
                <div class="orderbox">
                    <div class="topbox"><span class="fl">我的订单</span><span class="fr"><a href="${ctx}/orderInfo/orderInfoListByState">[查看全部订单]</a></span></div>
                    <div class="ordercon" style="padding: 20px 0;">
                         <c:if test="${ empty orderInfoListAll}"> 
                         <div class="ordercon" style="padding: 20px 0;line-height:180px;">
                        	<img style="vertical-align: -22px;" src="${ctx}/images/page/pe7.png"><span class="notext">您还没有任何订单，去逛逛吧 !</span>
                         </div>
                         </c:if> 
                         <div id="order">
	                        <c:if test="${ not empty orderInfoListAll}">
	                        	<table class="table" id="tab">
	                            <thead>
	                                <tr>
	                                    <th width="30%">商品信息</th>
	                                    <th width="10%">单价(元)</th>
	                                    <th width="10%">数量</th>
	                                    <th width="10%">实付款</th>
	                                    <th width="10%">交易状态</th>
	                                    <th width="10%">操作</th>
	                                </tr>
	                            </thead>
	                            <tbody id="tableTbody">
	                                    <c:forEach items="${orderInfoListAll}" var="orderInfo" varStatus="status">
	                                    <c:if test="${status.index < 5 }">
	                                    	<tr><td colspan="6" style="padding:17px 0;"></td></tr>
	                                        <tr class="orderTimeShopName">
	                                            <td colspan="6"style="border-bottom:1px solid #ccc;">
	                                            	<div class="orderTimeShopNameDetail">
	                                                    <span <c:if test="${orderInfo.orderLevel == 2 }"> style="padding-left:40px" </c:if>><fmt:formatDate value="${orderInfo.createTime}" pattern="yyyy-MM-dd" /></span>
	                                                    <span style="padding-left:10px">订单号：${orderInfo.orderNumber}</span>
		                                                <span  style="padding-left:80px;line-height: 33px;">
		                                                <c:if test="${orderInfo.orderLevel == 2 }">
			                                                <c:if test="${orderInfo.type == 1 }">
			                                                	<img style="vertical-align: -3px;" src="${ctx}/images/gwc/shop.png">&nbsp;${orderInfo.shopName}
			                                                </c:if>
			                                                <c:if test="${orderInfo.type == 2 }">
			                                                	<img style="vertical-align: -3px;" src="${ctx}/images/gwc/shop.png">&nbsp;积分商品
			                                                </c:if>
			                                                <c:if test="${orderInfo.type == 3 }">
			                                                	<img style="vertical-align: -3px;" src="${ctx}/images/gwc/shop.png">&nbsp;秒杀商品
			                                                </c:if>
		                                                </c:if>
		                                                </span>
	                                                </div>
	                                               
	                                            </td>
	                                        </tr>
	                                        <c:forEach items="${orderInfo.orderDetailList}" var="orderDetailInfo" varStatus="orderDetailStatus">
	                                            <tr class="shop-info-tr">
	                                                <td class="goods"width="30%">
	                                                    <div class="image"style="float: left;">
	                                                        <c:if test="${ not empty orderDetailInfo.goodsInfo.logo}">
	                                                            <a href="${ctx}/GoodsDetail?id=${orderDetailInfo.goodsId}&type=${orderDetailInfo.goodsInfo.type}" target="_blank">
	                                                            	<img width="70px" height="70px" src="${sessionScope.image_logo}${orderDetailInfo.goodsInfo.logo}" />
	                                                            </a>
	                                                        </c:if>
	                                                        <c:if test="${ empty orderDetailInfo.goodsInfo.logo}">
		                                                        <a href="${ctx}/GoodsDetail?id=${orderDetailInfo.goodsId}&type=${orderDetailInfo.goodsInfo.type}" target="_blank">
		                                                            <img width="70px" height="70px" src="${ctx}/images/news/cellManual/default.png" />
		                                                        </a>
	                                                        </c:if>
	                                                    </div>
	                                                    <div style="float:left;">
	                                                        <p><span style="float:left;">${orderDetailInfo.goodsInfo.name}</span></p><br/>
	                                                        <c:forEach items="${orderDetailInfo.specNameValueList}" var="specNameValue" varStatus="specNameValueStatus">
	                                                            <p style="display:inline"><span >${specNameValue.attrName}:</span>
	                                                                    <span>${specNameValue.attrValue}</span></p>
	                                                        </c:forEach>
	                                                    </div>
	                                                </td>
	                                                <td width="10%">￥${orderDetailInfo.price}</td>
	                                                <td width="10%">${orderDetailInfo.amount}</td>
	                                                <c:if test="${orderDetailStatus.index == 0 }">
	                                                    <td width="10%" style="border-left:1px solid #ccc" rowspan="${fn:length(orderInfo.orderDetailList)}">
	                                                        ${orderInfo.finalPrice}<br />
	                                                        (含运费${orderInfo.carriage})
	                                                    </td>
	                                                </c:if>
	                                                <c:if test="${orderDetailStatus.index == 0 }">
	                                                    <td width="10%" style="border-left:1px solid #ccc" rowspan="${fn:length(orderInfo.orderDetailList)}">
		                                                      <c:if test="${orderInfo.state == 3 || orderInfo.state == 14 }">
		                                                	      <p>待收货</p></c:if>
		                                                	  <c:if test="${orderInfo.state == 9 }">
								                              	  <p>待消费</p>
								                              </c:if>
								                              <c:if test="${orderInfo.state == 0 }">
								                              	  <p>待付款</p>
								                              </c:if>
								                              <c:if test="${orderInfo.state == 1 }">
								                               		<p>待商家确认</p>
							                               	  </c:if>
								                              <c:if test="${orderInfo.state == 2 }">
								                              	    <p>待发货</p></c:if>
								                              <c:if test="${orderInfo.state == 4 }">
							                              	         <p>已完成</p></c:if>
								                              <c:if test="${orderInfo.state == 5 }">
						                              	          	 <p>订单已取消</p></c:if>
								                              <c:if test="${orderInfo.state == 6 }">
								                              	     <p>退款申请</p></c:if>
								                              <c:if test="${orderInfo.state == 7 }">
								                              	 	<p>退款已确认</p></c:if>
								                              <c:if test="${orderInfo.state == 8 }">
								                             	    <p>退款完成</p></c:if>
								                              <c:if test="${orderInfo.state == 10 }">
								                            	    <p>退货申请</p></c:if>
								                              <c:if test="${orderInfo.state == 11 }">
								                              		<p>退货已确认</p></c:if>
								                              <c:if test="${orderInfo.state == 12 }">
								                             		<p>退货已完成</p></c:if>
								                              <c:if test="${orderInfo.state == 13 }">
								                              		<p>退货已拒绝</p></c:if>
	                                                        <%-- <c:if test="${orderInfo.state == 0}">
	                                                            <p>等待买家付款</p>
	                                                        </c:if> 
	                                                        <c:if test="${orderInfo.state == 9 || orderInfo.state == 14 || orderInfo.state == 3}">
	                                                        </c:if> 
	                                                        <c:if test="${orderInfo.state == 1 || orderInfo.state == 2}">
	                                                            <p>买家已付款</p>
	                                                        </c:if> 
	                                                        <c:if test="${orderInfo.state == 4}">
	                                                            <p>交易成功</p>
	                                                        </c:if>  --%>
	                                                        <a title="订单详情" onclick="orderDetail(${orderInfo.id});">订单详情</a>
	                                                    </td>
	                                                </c:if>
	                                                <c:if test="${orderDetailStatus.index == 0 }">
	                                                    <td width="10%" style="border-left:1px solid #ccc" rowspan="${fn:length(orderInfo.orderDetailList)}">
	                                                        <c:if test="${orderInfo.state == 0}">
	                                                            <a class="payMoney"title="立即付款" onclick="payMoney('${orderInfo.id}');">立即付款</a>
	                                                            <a title="取消订单" onclick="cancelOrder(${orderInfo.id});">取消订单</a>
	                                                        </c:if> 
	                                                        <c:if test="${orderInfo.state == 14 || orderInfo.state == 3}">
	                                                            <a class="comfirm"title="确认收货" onclick="confirmReceiveGoods('${orderInfo.id}');;">确认收货</a>
	                                                            <a title="投诉卖家" onclick="complainSeller();">投诉卖家</a>
	                                                        </c:if> 
	                                                        <c:if test="${orderInfo.state == 9 }">
	                                                            <a class="comfirm"title="确认收货" onclick="confirmConsume('${orderInfo.id}');">确认消费</a>
	                                                            <a title="投诉卖家" onclick="complainSeller();">投诉卖家</a>
	                                                        </c:if> 
	                                                        <c:if test="${orderInfo.state == 1 || orderInfo.state == 2}">
		                                                        <c:if test="${orderInfo.type == 1}">
		                                                            <a title="申请退款" onclick="applyRefundOrGoods('${orderInfo.id}');">申请退款</a>
		                                                            <br />
	                                                            </c:if>
	                                                            <a title="投诉卖家" onclick="complainSeller();">投诉卖家</a>
	                                                        </c:if> 
	                                                        <c:if test="${orderInfo.state == 4}">
	                                                            <c:if test="${orderInfo.type == 1}">
	                                                            	<a title="申请退货" onclick="applyRefundOrGoods('${orderInfo.id}');">申请退货</a>
	                                                           		 <br/>
                                                            	</c:if>
	                                                            <input type="hidden" id="shopId" value="${orderDetailInfo.shopId}"/> 
	                                                            <a title="投诉卖家" onclick="complainSeller();">投诉卖家</a>
	                                                        </c:if> 
	                                                        <c:if test="${orderInfo.state == 6 || orderInfo.state == 10}">
	                                                            <a title="投诉卖家" onclick="complainSeller();">投诉卖家</a>
	                                                        </c:if>
	                                                    </td>
	                                                </c:if>
	                                            </tr>
	                        
	                                        </c:forEach>
	                                        </c:if>
	                                    </c:forEach>
	                            </tbody> 
	                            </table>
	                        </c:if>
                        </div> 
                    </div>
                </div>
                <div class="orderbox">
                    <div class="topbox"><span class="fl">我的收藏</span><span class="fr"><a href="${ctx}/ownerOther/getMyCollection">[查看全部收藏]</a></span></div>
                    <div class="ordercon" style="padding-bottom: 20px ;">
                    	<c:if test="${ empty myCollection}">
                    	<div class="ordercon" style="padding: 20px 0;line-height:180px;">
                        	<img style="vertical-align: -20px;" src="${ctx}/images/page/pe8.png"><span class="notext">您还没有收藏任何商品，先去逛逛吧 !</span>
                        </div>
                        </c:if>
                        <c:if test="${ not empty myCollection}">
							<div class="item-wrap">
								<c:forEach items="${myCollection}" var="item" varStatus="status">
								    <c:if test="${status.index < 5 }">
										<div class="item-box-wrap">
											<div class="item-pic-box">
											    	<img width="100" height="100" src="${sessionScope.image_logo}${item.logo}">
											</div>
											<div>
												<input id="ownerId"  type="hidden" value="${sessionScope.user_login.id}">	
												<p>${item.name}</p>
												<p class="text-color" style="margin-bottom:15px;font-size:16px;font-weight:700">￥${item.price}</p>	
												<input type="button" value="加入购物车" class="add-cart" onclick="addToShopCar('${item.name}','${item.goodsId}',
												'${item.shopId}','${item.logo}','${item.price}','${item.type}')">&nbsp;&nbsp;
												<a class="text-color" onclick="removeCollection(${item.goodsId})">取消收藏</a>						
											</div>
										</div>
									</c:if>
								</c:forEach>
					     </div>
                      </c:if>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="returnAli"></div>
    <jsp:include page="/views/common/footer.jsp" />
    <script type="text/javascript">
    
	    var ctx = '${ctx}';
	    
	    setCtx(ctx);
    
    	function changePassword(userId){
    		msg = "修改密码";
    		url = "${ctx}"+ "/user/changePassword?id=" + userId ;
    		index = layer.open({
    		    type: 2,
    		    skin: 'changePw',
    		    title: msg,
    	    	fix: false,
    	      	shadeClose: true,
    		    scrollbar: false,
    		    maxmin: false,
    	      	edit: true,
    	      	closeBtn: 1,
    	      	area: ['480px', '300px'],
    	      	content: url,
    	      	btn: ['确定', '取消']
    		    	,yes: function(index, layero){ //或者使用btn1
    		        	//按钮【按钮一】的回调
    		    		var iframeWin = window[layero.find('iframe')[0]['name']]; 
    		    		iframeWin.savePwd();

    		    	},cancel: function(index){ //或者使用btn2
    		        	//按钮【按钮二】的回调
    		    	}
    			});
    	}
    	function gotoBindPhone() {
    		
    	}
    	
    	function removeCollection(goodsId) {
    		var ownerId =  $('#ownerId').val();
    		$.ajax({
    			type : "GET",
    			url : ctx + "/ownerOther/collectionRemove",
    			cache : false,
    			dataType : 'json',
    			data : {
    				ownerId : ownerId,
    				goodsId : goodsId
    			},
    			success : function(result) {
    				if (result.success) {
    					layer.msg("取消收藏成功", {
    						icon : 1,
    						time : 3000
    					// 2秒关闭（如果不配置，默认是3秒）
    					}, function() {
    						window.location.href=ctx+"/main?item=6";
    					});
    				} else {
    					layer.msg("取消收藏失败", {
    						icon : 2,
    						time : 3000
    					});
    				}
    			}
    		});
    	}
    	
    	function addToShopCar(name,goodsId,shopId,logo,price,type) {
    		$.ajax({
    			type : "POST",
    			url : ctx + "/shopcart/addToCart",
    			cache : false,
    			dataType : 'json',
    			data : {
    				name     : name,
    				goodsId  : goodsId,
    				shopId   : shopId,
    				logo     : logo,
    				price    : price,
    				type     : type,
    				count    : 1
    			},
    			success : function(result) {
    				if (result.success) {
    					layer.msg("加入购物车成功", {
    						icon : 1,
    						time : 3000
    					// 2秒关闭（如果不配置，默认是3秒）
    					});
    				} else {
    					layer.msg("加入购物车失败", {
    						icon : 2,
    						time : 3000
    					});
    				}
    			}
    		});
    	}
    	
    </script>
       <!-- 解决ie 6 7 8 9不能显示placeholder的问题 -->
    <script src="${ctx}/js/lib/jquery.JPlaceholder.js"></script>
</body>
</html>